package api

import (
	"litetalk/api/router"
	"litetalk/config"
	"net/http"

	"github.com/sirupsen/logrus"
)

func GoRun() {
	r := router.Register()

	srv := &http.Server{
		Addr:    config.Conf.Api.Bind,
		Handler: r,
	}

	go func() {
		logrus.Infof("Api listen on addr: [%s]", srv.Addr)
		if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
			logrus.Errorf("api listen: %s over\n", err)
		}
	}()
}
